package oa.hleast.xswl.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import oa.hleast.xswl.mapper.SysCommonConfigMapper;
import oa.hleast.xswl.pojo.domain.SysCommonConfig;
import oa.hleast.xswl.service.ISysCommonConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author 302
 */
@Transactional
@Slf4j
@Service
public class SysCommonConfigServiceImpl extends ServiceImpl<SysCommonConfigMapper, SysCommonConfig> implements ISysCommonConfigService {

    @Override
    public SysCommonConfig getByConfigKey(String configKey) {
        LambdaQueryWrapper<SysCommonConfig> queryWrapper = new LambdaQueryWrapper<SysCommonConfig>()
                .eq(SysCommonConfig::getConfigKey, configKey);
        SysCommonConfig commonConfig = this.getOne(queryWrapper);
        log.info("从数据库中获取系统配置, configKey = {} ,commonConfig = {}", configKey, commonConfig);
        return commonConfig;
    }
}
